package com.designPatterns.command;

public class LightOffCommand implements Command {
	private Light light;
	private String lastActionString="";
	public void setLight(Light light) {
		this.light = light;
	}
	
	public LightOffCommand(Light light) {
		super();
		this.light = light;
	}

	@Override
	public void execute() {
		light.LightOff();
		lastActionString="on";
	}

	@Override
	public void undo() {
		if(lastActionString.equals("on")){
			light.LightOn();
		}else {
			light.LightOff();
		}
	}

}
